// Tags:
#include <cctype>
#include <cstdio>

typedef long long ll;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

int n, k;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("paint.in", "r", stdin);
  freopen("paint.out", "w", stdout);
#endif
#endif

  read(k);
  for (ll n; k; --k) {
    read(n);
    for (int i = 2; (ll)i * i <= n; ++i) {
      if (n % i == 0) {
        while (n % i == 0) n /= i;
        if (n != 1) {
          putchar('1');
          goto end;
        } else {
          printf("%d", i);
          goto end;
        }
      }
    }
    printf("%lld", n);
  end:
    puts("");
  }
  return 0;
}